package com.info.zhiduoduo.repository.dto.entrustmentproject;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.info.zhiduoduo.common.excelconverter.EntrustProjectStateConverter;
import com.info.zhiduoduo.common.excelconverter.ProjectTypeConverter;
import com.info.zhiduoduo.common.utils.DateUtil;
import com.info.zhiduoduo.common.utils.NumberUtil;

import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.Date;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class MakerGroupProjectItemExportVO {

	@ExcelProperty("项目名")
	private String name;
	@ExcelProperty("企业名称")
	private String compname;
	@ExcelProperty("创客姓名")
	private String entrusteeName;
	@ExcelProperty("创客工作室名称")
	private String entrusteeStudio;
	@ExcelProperty("项目内容")
	private String content;
	@ExcelProperty(value = "项目类型", converter = ProjectTypeConverter.class)
	private Integer projectType;
	@ExcelProperty("项目金额,单位元")
	private BigDecimal projectAmount;
	@ExcelProperty("实发金额,单位元")
	private BigDecimal amount;
	@ExcelProperty("含税金额(实发金额+服务费+税费),单位元")
	private BigDecimal taxInclusiveAmount;
	@ExcelProperty("发票内容")
	private String invoiceContent;
	@ExcelProperty("收款方姓名")
	private String payeeName;
	@ExcelProperty("收款方手机号")
	private String phone;
	@ExcelProperty("收款方身份证号")
	private String payeeIdNo;
	@ExcelProperty("收款账号类型")
	private String accountType;
	@ExcelProperty("收款账号")
	private String accountNo;
	@ExcelProperty(value = "项目状态", converter = EntrustProjectStateConverter.class)
	private Integer state;
	@ExcelProperty("项目发布时间")
	@DateTimeFormat(DateUtil.FORMAT_STYLE_1)
	private Date dispatchTime;
	@ExcelProperty("支付时间")
	@DateTimeFormat(DateUtil.FORMAT_STYLE_1)
	private Date payTime;
	@ExcelProperty("项目结束时间")
	@DateTimeFormat(DateUtil.FORMAT_STYLE_1)
	private Date finishTime;

	public static MakerGroupProjectItemExportVO of(EntrustmentProjectItemDto dto) {
		MakerGroupProjectItemExportVO exportDto = new MakerGroupProjectItemExportVO();
		BeanUtils.copyProperties(dto, exportDto);
		if (NumberUtil.equals(dto.getAccountType(), 1)) exportDto.setAccountType("支付宝");
		else exportDto.setAccountType("银行卡");

		return exportDto;
	}
}
